<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>
    <link rel="stylesheet" type="text/css" href="../../css/defaultcss.css" />
    <link rel="stylesheet" type="text/css" href="../../css/amazeui.min.css" />
    <script type="text/javascript" src="../../js/jquery-1.9.1.min.js"></script>
    <script src='../../js/amazeui.min.js'></script>
    <script src='../../js/flex.js'></script>
    <script src='../../layer/layer.js'></script>
    <script src='../../js/index.js'></script>
    <link rel="stylesheet" href="../../css/weui.min.css">
    <link rel="stylesheet" href="../../css/css/stylesheets/index.css">

</head>

<body>
    <header>
        <div class="goBack">
            <img src="../../img/base/back.png" alt="返回">
        </div>
        <span class="title"> 案件申请 </span>
    </header>
    <div class="content application_enquiry apply_form">
        <form id="fform">
            <ul class="form_ul">
                <div class="li_title">
                    案件信息
                </div>
                <li>
                    <label for="">案件名称</label>
                    <input type="text" name="caseName" value="" id="caseName" placeholder="">
                </li>
                <li>
                    <label for="">案件编号</label>
                    <input type="text" name="caseNo" value="" id="caseNo" placeholder="">
                </li>
                <li>
                    <label for="">当事人</label>
                    <input type="text" name="party" value="" id="party" placeholder="">
                </li>
                <li>
                    <label for="">律师证件号</label>
                    <input type="text" name="certificateNum" value="" id="certificateNum" placeholder="">
                </li>
                <div class="li_title">
                    证明材料
                </div>
                <li class="img_box">
                    <div class="img">
                        <img src="../../img/lawsuit/img.png" alt="">
                        <input type="file" id="file1" name="" />
                        <i>      
                            <img src="../../img/lawsuit/delete.png" alt="">      
                        </i>
                        <img src="" alt="" id="apfileimg1" class="imgFile">
                    </div>
                    <div class="img">
                        <img src="../../img/lawsuit/img.png" alt="">
                        <input type="file" id="file2" name="" />
                        <i>
                            <img src="../../img/lawsuit/delete.png" alt="">      
                        </i>
                        <img src="" alt="" id="apfileimg2" class="imgFile">
                    </div>
                </li>
                <div class="form_tips1">
                    注：证明材料包含律师证、律师授权委托书。
                </div>
            </ul>
        </form>
        <div class="submitBtn">
            <button class="button" type="submit" id="submit">
					申请绑定
				</button>
        </div>
    </div>
    <div class="am-modal am-modal-alert radiusModal" tabindex="-1" id="lawsuitModal">
        <div class="am-modal-dialog">
            <div class="am-modal-hd">温馨提示</div>
            <div class="am-modal-bd">
                绑定审核中...</br>请耐心等待！
            </div>
            <div class="am-modal-footer">
                <a href='./lawer_serve.html' class="am-modal-btn">确定</a>
            </div>
        </div>
    </div>
</body>

</html>


<script type="text/javascript">
    $(".img_box .img i").hide();
    var certificateImgId = '';
    var authorizationImgId = '';
    var lawyerId = 111;
    $("#submit").bind('click', function () {
        var caseName = $("#caseName").val();
        var caseNo = $("#caseNo").val();
        var party = $('#party').val();
        var certificateNum = $('#certificateNum').val();
        if (caseName == "") {
            layer.open({
                title: '提示',
                content: "案件名称不能为空！",
                btn: ['确定'],
            });
            return false;
        } else if (caseNo == "") {
            layer.open({
                title: '提示',
                content: "案件编号不能为空！",
                btn: ['确定'],
            });
            return false;
        } else if (party == '') {
            layer.open({
                title: '提示',
                content: "当事人不能为空！",
                btn: ['确定'],
            });
            return false;
        } else if (certificateNum == "") {
            layer.open({
                title: '提示',
                content: "律师证件号不能为空！",
                btn: ['确定'],
            });
            return false;
        } else if (certificateImgId == '' || authorizationImgId == '') {
            layer.open({
                title: '提示',
                content: "图片不能为空！",
                btn: ['确定'],
            });
            return false;
        }

        var form = new FormData($('#fform')[0]);
        form.append("lawyerId", lawyerId);
        form.append("certificateImgId", certificateImgId);
        form.append("authorizationImgId", authorizationImgId);
        console.log(form.get('lawyerId'));
        console.log(form.get('certificateImgId'));
        console.log(form.get('authorizationImgId'));
        HYIP.ajax({
            url: '/lawyerCase/applyBindingCase.action',
            type: 'post',
            processData: false,
            data: form
        }, function (data) {
            $("#lawsuitModal").modal('open');
        });
        return false;
    })
    $(".am-modal-footer").bind('click', function () {
        window.location.href = './lawer_serve.html'
    })
    $(function () {
        $("#file1").on("change", function (e) {
            var file = e.currentTarget.files[0]
            $("#apfileimg1").show();
            $(this).siblings("i").show();
            if (this.files && file) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    $("#apfileimg1").attr("src", e.target.result);
                }
                reader.readAsDataURL(file);
                var formFile = new FormData();
                formFile.append("file", file);
                formFile.append("fileType", 1);
                formFile.append("recordType", 8);
                console.log(formFile.get('file'))
                HYIP.ajax({
                    url: '/file/upload.action',
                    type: 'post',
                    contentType: false, // 不转换file
                    processData: false,
                    traditional: true,
                    cache: false,
                    data: formFile
                }, function (data) {
                    console.log(data)
                    certificateImgId = data.data;
                    // $("#lawsuitModal").modal('open');
                });
            }
        });
        $("#file2").on("change", function (e) {
            var file = e.currentTarget.files[0]
            $("#apfileimg2").show();
            $(this).siblings("i").show();
            if (this.files && file) {
                var reader = new FileReader();
                reader.onload = function (e) {
                    $("#apfileimg2").attr("src", e.target.result);
                }
                reader.readAsDataURL(file);
                var formFile = new FormData();
                formFile.append("file", file);
                formFile.append("fileType", 1);
                formFile.append("recordType", 7);
                console.log(formFile.get('file'))
                HYIP.ajax({
                    url: '/file/upload.action',
                    type: 'post',
                    contentType: false, // 不转换file
                    processData: false,
                    traditional: true,
                    cache: false,
                    data: formFile
                }, function (data) {
                    console.log(data)
                    authorizationImgId = data.data;
                    // $("#lawsuitModal").modal('open');
                });
            }
        });
    })
    $('.goBack').bind('click', function () {
        window.history.back()
    })
</script>